package SimpleFactoryMode.version2;

import java.util.Scanner;

/**
 * Created by ycq on 2018/9/7.
 */
public class version2 {

    public static void main(String[] args) {
        try {
            Scanner in=new Scanner(System.in);
            System.out.println("请输入数字A：");
            String strNumberA= in.next();
            System.out.println("请输入运算符号");
            String strOperate=in.next();
            System.out.println("请输入数字B");
            String strNumberB=in.next();
            String strResult="";
            switch(strOperate)
            {
                case "+":
                    strResult=String.valueOf(Double.parseDouble(strNumberA)+Double.parseDouble(strNumberB));
                    break;
                case "-":
                    strResult=String.valueOf(Double.parseDouble(strNumberA)-Double.parseDouble(strNumberB));
                    break;
                case "*":
                    strResult=String.valueOf(Double.parseDouble(strNumberA)*Double.parseDouble(strNumberB));
                    break;
                case "/":
                    if(strNumberB!="0")
                    strResult=String.valueOf(Double.parseDouble(strNumberA)/Double.parseDouble(strNumberB));
                else
                    strResult="除数不能为0";
                break;
            }
            System.out.println("结果是"+strResult);
        } catch (NumberFormatException e) {
            System.out.println("您的输入有错"+e.getMessage());
        }
    }
}
